package com.zt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zt.service.AccountOpeningService;
import com.zt.mapper.AccountOpeningMapper;
import com.zt.vo.CardBindingVo;
import com.zt.system.AccountOpening;
import com.zt.utils.Result;
import com.zt.vo.Vo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import javax.annotation.Resource;
import java.util.Random;

/**
* @author 不.凌
* @description 针对表【account_opening】的数据库操作Service实现
* @createDate 2024-09-03 17:42:54
*/
@Service
public class AccountOpeningServiceImpl extends ServiceImpl<AccountOpeningMapper, AccountOpening>
    implements AccountOpeningService{
    @Resource
    private AccountOpeningMapper accountOpeningMapper;
    //开户

    @Override
    public Result saveAccount(AccountOpening accountOpening) {
        Random random = new Random();
        StringBuilder cardNumber = new StringBuilder("6");
        for (int i = 1; i < 20; i++) {
            cardNumber.append(random.nextInt(10));
        }
        accountOpening.setOpenTwo(String.valueOf(cardNumber));
        accountOpeningMapper.insert(accountOpening);
        return Result.success("成功");

    }
//查询银行卡的密码
    @Override
    public Result getCardNumber(String bankNumber) {
        AccountOpening accountOpening = accountOpeningMapper.getCardNumber(bankNumber);
        return Result.success(accountOpening);
    }

    @Override
    public Result savepassword(Integer openingId, String bankNumber) {
        AccountOpening accountOpeningId = accountOpeningMapper.selectById(openingId);
        accountOpeningId.setBankNumber(Integer.valueOf(bankNumber));
        accountOpeningMapper.updateById(accountOpeningId);
        return Result.success("成功");
    }


}




